**  "SalehayenGleditsch_IO06"

use "IOrepdata.dta", clear

merge m:1 ccode using cites.dta , gen(m1)
drop if m1==2
gen cites = year>=citesyr

gen study = ""
foreach n in orig noth fe time fet ct yfe cyfe {
gen method_`n' = ""
gen dv_`n' = ""
gen b_cites_`n' = .
gen se_cites_`n'= .
gen pval_cites_`n' = .
gen lo_cites_`n'=.
gen hi_cites_`n'=.
gen N_cites_`n'=.
}
gen studynum=.
gen timetrend=""
qui do cites.do
local ii = 1
*Table 4, model 1
*Controls only
xtset ccode year
* model 1
logit nonset cites nbcwbin polityb polityb2 lngdp lnpop het peace1 s1a s2a s3a , robust
cites `ii' orig
logit nonset cites nbcwbin polityb polityb2 lngdp lnpop het  , robust
cites `ii' noth
xtlogit nonset cites nbcwbin polityb polityb2 lngdp lnpop het  ,  fe
cites `ii' fe
logit nonset cites nbcwbin polityb polityb2 lngdp lnpop het peace1 s1a s2a s3a , robust
cites `ii' time 
xtlogit nonset cites nbcwbin polityb polityb2 lngdp lnpop het s1a s2a s3a ,  fe
cites `ii' fet
logit nonset cites nbcwbin polityb polityb2 lngdp lnpop het s1a s2a s3a i.ccode#c.year , cl(ccode)  
cites `ii' ct
clogit nonset cites nbcwbin polityb polityb2 lngdp lnpop het  ,  group(year) vce(cl year)
cites `ii' yfe
xtreg nonset cites nbcwbin polityb polityb2 lngdp lnpop het i.year ,  fe vce(cl ccode)
cites `ii' cyfe
replace studynum = `ii' if _n==`ii'   
replace timetrend="splines" if _n==`ii'
local ii=`ii'+1
* Table 4, model 2
* Add refugees from neighboring states within 100km
* model 2
logit nonset cites logref2 nbcwbin polityb polityb2 lngdp lnpop het peace1 s1a s2a s3a , robust
cites `ii' orig
logit nonset cites logref2 nbcwbin polityb polityb2 lngdp lnpop het  , robust
cites `ii' noth 
xtlogit nonset cites logref2 nbcwbin polityb polityb2 lngdp lnpop het  ,  fe
cites `ii' fe
logit nonset cites logref2 nbcwbin polityb polityb2 lngdp lnpop het peace1 s1a s2a s3a , robust
cites `ii' time
xtlogit nonset cites logref2 nbcwbin polityb polityb2 lngdp lnpop het s1a s2a s3a ,  fe
cites `ii' fet
logit nonset cites logref2 nbcwbin polityb polityb2 lngdp lnpop het s1a s2a s3a i.ccode#c.year , cl(ccode) 
cites `ii' ct
clogit nonset cites logref2 nbcwbin polityb polityb2 lngdp lnpop het  ,  group(year) vce(cl year)
cites `ii' yfe
xtreg nonset cites logref2 nbcwbin polityb polityb2 lngdp lnpop het i.year ,  fe vce(cl ccode)
cites `ii' cyfe
replace studynum = `ii' if _n==`ii'   
replace timetrend="splines" if _n==`ii'
local ii=`ii'+1


*Table 5, model 3
*Include ethnic kin in neighbors
logit nonset cites logref2 nbcwbin ethnicnb polityb polityb2 lngdp lnpop  het peace1  s1a s2a s3a  , robust
cites `ii' orig
logit nonset cites logref2 nbcwbin ethnicnb polityb polityb2 lngdp lnpop  het   , robust
cites `ii' noth
xtlogit nonset cites logref2 nbcwbin ethnicnb polityb polityb2 lngdp lnpop  het   , fe
cites `ii' fe
logit nonset cites logref2 nbcwbin ethnicnb polityb polityb2 lngdp lnpop  het peace1  s1a s2a s3a  , robust
cites `ii' time
xtlogit nonset cites logref2 nbcwbin ethnicnb polityb polityb2 lngdp lnpop  het peace1 s1a s2a s3a  , fe
cites `ii' fet
logit nonset cites logref2 nbcwbin ethnicnb polityb polityb2 lngdp lnpop  het  i.ccode#c.year , robust
cites `ii' ct
clogit nonset cites logref2 nbcwbin ethnicnb polityb polityb2 lngdp lnpop  het   , group(year) vce(cl year)
cites `ii' yfe
xtlogit nonset cites logref2 nbcwbin ethnicnb polityb polityb2 lngdp lnpop  het i.year  , fe 
cites `ii' cyfe
replace studynum = `ii' if _n==`ii'   
replace timetrend="splines" if _n==`ii'
local ii=`ii'+1

*Table 5, model 4
*Restrict to large wars
logit bigconset cites logref2 nbcwbin polityb polityb2 lngdp lnpop het peace2 s1c s2c s3c  , robust
cites `ii' orig
logit bigconset cites logref2 nbcwbin polityb polityb2 lngdp lnpop het    , robust
cites `ii' noth
xtlogit bigconset cites logref2 nbcwbin polityb polityb2 lngdp lnpop het   , fe
cites `ii' fe
logit bigconset cites logref2 nbcwbin polityb polityb2 lngdp lnpop het peace2 s1c s2c s3c  , robust
cites `ii' time
xtlogit bigconset cites logref2 nbcwbin polityb polityb2 lngdp lnpop het peace2 s1c s2c s3c   , fe
cites `ii' fet
logit bigconset cites logref2 nbcwbin polityb polityb2 lngdp lnpop het i.ccode#c.year   , robust
cites `ii' ct
clogit bigconset cites logref2 nbcwbin polityb polityb2 lngdp lnpop het   , group(year) vce(cl year)
cites `ii' yfe
xtlogit bigconset cites logref2 nbcwbin polityb polityb2 lngdp lnpop het i.year   , fe 
cites `ii' cyfe
replace studynum = `ii' if _n==`ii'   
replace timetrend="splines" if _n==`ii'
local ii=`ii'+1

*Table 5, model 5
*Refugees per 1,000
logit nonset cites lrefpct nbcwbin polityb polityb2 lngdp  lnpop  het peace1  s1a s2a s3a , robust
cites `ii' orig
logit nonset cites lrefpct nbcwbin polityb polityb2 lngdp  lnpop  het , robust
cites `ii' noth
xtlogit nonset cites lrefpct nbcwbin polityb polityb2 lngdp  lnpop  het , fe
cites `ii' fe
logit nonset cites lrefpct nbcwbin polityb polityb2 lngdp  lnpop  het peace1  s1a s2a s3a , robust
cites `ii' time
xtlogit nonset cites lrefpct nbcwbin polityb polityb2 lngdp  lnpop  het peace1  s1a s2a s3a , fe
cites `ii' fet
logit nonset cites lrefpct nbcwbin polityb polityb2 lngdp  lnpop  het i.ccode#c.year , robust
cites `ii' ct
clogit nonset cites lrefpct nbcwbin polityb polityb2 lngdp  lnpop  het  , group(year) vce(cl year)
cites `ii' yfe
xtlogit nonset cites lrefpct nbcwbin polityb polityb2 lngdp  lnpop  het i.year, fe 
cites `ii' cyfe
replace studynum = `ii' if _n==`ii'   
replace timetrend="splines" if _n==`ii'
local ii=`ii'+1

*Table 5, model 6
*Refugees per 1,000 and ethnic kin
logit nonset cites lrefpct nbcwbin ethnicnb polityb polityb2 lngdp  lnpop  het peace1  s1a s2a s3a , robust
cites `ii' orig
logit nonset cites lrefpct nbcwbin ethnicnb polityb polityb2 lngdp  lnpop  het  , robust
cites `ii' noth
xtlogit nonset cites lrefpct nbcwbin ethnicnb polityb polityb2 lngdp  lnpop  het  , fe
cites `ii' fe
logit nonset cites lrefpct nbcwbin ethnicnb polityb polityb2 lngdp  lnpop  het peace1  s1a s2a s3a , robust
cites `ii' time
xtlogit nonset cites lrefpct nbcwbin ethnicnb polityb polityb2 lngdp  lnpop  het peace1  s1a s2a s3a , fe
cites `ii' fet
logit nonset cites lrefpct nbcwbin ethnicnb polityb polityb2 lngdp  lnpop  het i.ccode#c.year  , robust
cites `ii' ct
clogit nonset cites lrefpct nbcwbin ethnicnb polityb polityb2 lngdp  lnpop  het  , group(year) vce(cl year)
cites `ii' yfe
xtlogit nonset cites lrefpct nbcwbin ethnicnb polityb polityb2 lngdp  lnpop  het i.year , fe 
cites `ii' cyfe
replace studynum = `ii' if _n==`ii'   
replace timetrend="splines" if _n==`ii'
local ii=`ii'+1



replace study = "Salehayen Gleditsch" if studynum~=. 	

keep study-timetrend
drop if studynum==.
compress
save salehayengleditsch.dta , replace
